package com.jzy.message.activities.common;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.jzy.message.R;
import com.jzy.message.activities.base.BaseActivity;
import com.jzy.message.activities.base.DialogWaiting;
import com.jzy.message.control.photoview.PhotoView;
import com.jzy.message.util.image.ImageConfig;

import org.xutils.common.Callback;
import org.xutils.x;

/**
 * Created by Administrator on 2016/7/3.
 */
public class ShowPictruerActivity extends BaseActivity {
    private PhotoView iv_common_picshower;
    private ImageLoadingDialog dialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.common_imageshower);
        thisActivity=this;
        dialog = new ImageLoadingDialog(this);
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
        findview();
        showPic();

    }
    private void findview()
    {
        iv_common_picshower=(PhotoView) findViewById(R.id.iv_common_picshower);
    }
    private void showPic()
    {
        String[] contents = getIntent().getStringArrayExtra("Paras");
        String ThumbnailImageUrl=contents[0];
        String SourceImageUrl=contents[1];
        //x.image().bind(iv_common_picshower,ThumbnailImageUrl,ImageConfig.image_options_default);//显示小图
        //显示大图
        x.image().loadDrawable(SourceImageUrl, ImageConfig.image_options_default, new Callback.CommonCallback<Drawable>(){
            @Override
            public void onSuccess(Drawable drawable) {
                dialog.dismiss();
                iv_common_picshower.setImageDrawable(drawable);
            }
            @Override
            public void onError(Throwable throwable, boolean b) {

            }
            @Override
            public void onCancelled(CancelledException e) {

            }
            @Override
            public void onFinished() {

            }
        });

    }
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        finish();
        return true;
    }


}
